# -*- coding:UTF-8 -*-
# 开发人员: limenghui
# 开发时间：2024-09-21 上午11:20
# 文件名称：
# 开发工具：pycharm
import math
import time
from datetime import date, timedelta

import pandas as pd
import requests
from bs4 import BeautifulSoup

import os
import time

from selenium import webdriver

"""
指定默认下载路径, 下载链接是xxx.pdf的链接 如果浏览器直接打开则会显示pdf
https://www.cnblogs.com/lingwang3/p/14440087.html
https://www.codenong.com/81d215683e7fbf0ebd81/
"""
down_load_dir = os.path.abspath("./AAA/BBB/CCC")  # 浏览器会自动创建文件夹 写绝对路径
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches", ['enable-automation'])
prefs = {
    "download.default_directory": down_load_dir,
    "download.prompt_for_download": False,
    "download.directory_upgrade": True,
    "plugins.always_open_pdf_externally": True
}
options.add_experimental_option('prefs', prefs)
driver = webdriver.Chrome(options=options)
urls = ['http://xian.pbc.gov.cn/xian/129420/5464804/2024092017022173945.pdf', 'http://xian.pbc.gov.cn/xian/129420/5459969/2024091411283011648.pdf',
       'http://xian.pbc.gov.cn/xian/129420/5437124/2024082208422750048.pdf', 'http://xian.pbc.gov.cn/xian/129420/5434120/2024081915453524892.pdf',
       'http://xian.pbc.gov.cn/xian/129420/5415070/2024072617012687797.pdf', 'http://xian.pbc.gov.cn/xian/129420/5412108/2024072317252265225.pdf',
       'http://xian.pbc.gov.cn/xian/129420/5359860/2024052217070812305.pdf', 'http://xian.pbc.gov.cn/xian/129420/5356371/2024051715582316526.pdf',
       'http://xian.pbc.gov.cn/xian/129420/5341209/2024042917270623654.pdf', 'http://xian.pbc.gov.cn/xian/129420/5336112/2024042314321885575.pdf',
       'http://xian.pbc.gov.cn/xian/129420/5285899/2024032017032123259.pdf', 'http://xian.pbc.gov.cn/xian/129420/5275623/2024031514395097453.pdf',
       'http://xian.pbc.gov.cn/xian/129420/5250994/2024022617234433271.pdf', 'http://xian.pbc.gov.cn/xian/129420/5246434/2024022208161660157.pdf']
for url in urls:
    driver.get(url)
    time.sleep(3)
    driver.quit()
